<h2>Browse Grants</h2>

<div id="instruction">
These are the available grant cycles open to applicants.  
	<% if current_user.is_seeker? -%>
		To begin you application process, click on "Start Application". You will then be taken to a screen where you can fill out the application.
	<% end -%>                     
	 
	<% if current_user.is_admin? -%>
		<br />
		You can create new grant cycles from the existing applications on the <%= link_to 'Application Form', :controller => "form", :action => "list" %> page.
	<% end -%>  

</div>


<table>
  <tr>
		<th>Grant Name</th>
		<th>Opens</th>
		<th>Closes</th>
		<th>Notifies</th>    
		<th>Actions</th>
  </tr>
  
<% for cycle in @cycles %>
  <tr>
    <td><%=h cycle.name %></td>
    <td><%=h cycle.start_on.strftime("%b %d, %Y") %></td>
    <td><%=h cycle.close_on.strftime("%b %d, %Y")  %></td>
    <td><%=h cycle.notify_on.strftime("%b %d, %Y")  %></td>

    <td>
	    
	<% if current_user.is_admin? -%>
		      <%= link_to 'Edit', :action => 'edit', :id => cycle %><br />
	<% end -%>
			
			
	<% if current_user.is_seeker? and not current_user.submissions.find(:first, :conditions => ["cycle_id = ?", cycle.id]) -%>

		<% if cycle.close_on >= Date.today  %>	
		  <%= link_to "Start Application", :controller => "workitem", :action => "new", :id => cycle %><br />
		
		  
		<% else %>
		
		<font color="red">Closed</font>
		
		<% end %>
    <% end -%>
	  </td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @cycle_pages.current.previous } if @cycle_pages.current.previous %>
<%= link_to 'Next page', { :page => @cycle_pages.current.next } if @cycle_pages.current.next %> 